<%@page import="com.mconnect.msurvey.controller.PlanManager"%>
<%@page import="com.mconnect.msurvey.model.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@ taglib prefix="s" uri="/struts-tags"%>
<%
// w celu poprawnie dzialajacej sesji:
response.setHeader("Cache-Control","no-store"); 
response.setHeader("Pragma","no-cache"); 
response.setDateHeader ("Expires", 0); 
%>      
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
	  <title>mSurvey</title>
	  <link rel="stylesheet" href="resources/css/ap.css">
	  <link rel="stylesheet" href="js/jQuery/demos.css">
	  <link rel="stylesheet" href="js/jQuery/themes/base/jquery.ui.all.css">
  </head>

<body>
<div id="top">
	<div class="sessionUser">
    	<div id="logoMconnect">
    		<img src="resources/images/top_logo.gif" width="84" height="59" alt="image001"/>
    	</div>
    	<div id="mConnect_txt">
        	mConnect<br/>al. Jana Pawła II 41c<br/>31-864 Kraków
       </div>
    	
      <% User user = (User) session.getAttribute("user");
      	
      	 %>
    </div>
    <img src="resources/images/kreska.png" class="kreska">
    <div class="header_txt">
      <p class="header_txt_1">mSurvey</p>
      <p class="header_txt_2">Ankiety</p>
    </div>
    
    <ul id=menu>
     <%if(user == null){  %>
    	<jsp:forward page="loginUserForm.jsp"></jsp:forward>
      		
      	<%}else{ %>
      		<li  ><s:a action="index" id="hello">Witaj <%= user.getFirstname() + " " + user.getLastname() %></s:a></li>
			<li style="float: right"><s:a action="logoutUser">Wyloguj</s:a></li>
    </ul>
    
    <div id=kategorie>
   		<% 
   			PlanManager pM = new PlanManager();
			String typeOfSurvey = pM.getTypeOfPlan(user.getId_user());
			if(typeOfSurvey == null){%>
				<h2 style="text-align: center">Nie przypisano do ciebie żadnych ankiet.</h2>
					
			<%}else{ %>
				<center>
					<div class="demo" style="margin-top: 30px; margin-bottom: 30px;">
						<form action="index.jsp" method="post">
							<input type="submit" value="Przeprowadź ankietę" name="type" style="width: 200px; height: 40px;"/>
						</form>
					</div>
				</center>
				
				<%
				String type = request.getParameter("type");
				
				if(type != null && typeOfSurvey.equals("typical")){%>
					<jsp:forward page="surveyForm.jsp" />
					
				<%}else if(type != null && typeOfSurvey.equals("technical")){ %>
				<jsp:forward page="technicalSurveyForm.jsp" />
				
			<%	}
				
			}%>
			
    </div>
    <% } %>
</div>
  </body>
</html>